package tool;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import javax.xml.bind.annotation.adapters.HexBinaryAdapter;

public class PasswordEncryptor {
	
	public String encrypt(String password){
		MessageDigest messageDigest;
		try {
			messageDigest = MessageDigest.getInstance("SHA-512");
			byte[] byteEncryptedPassword=messageDigest.digest(password.getBytes());
			HexBinaryAdapter hexBinaryAdapter=new HexBinaryAdapter();
			String hexEncryptedPassword=hexBinaryAdapter.marshal(byteEncryptedPassword);
			return hexEncryptedPassword;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}

}
